<?php
require_once 'common.inc.php';
$table='localhash_1';
if('checksearch'==$action)
{

	if(!empty($stime)&&$stime>$etime)
		adminmsg('时间参数错误','man.inc.php');	
		
	$filtered = '';
	if(is_numeric($checktype))
	{
		$checktype = (int)$checktype;
		if(ereg("-[1-5]{1}",$checktype))
		{
			$var1 = 'checked1'.abs($checktype);
			$$var1 = 'checked="checked"';
			$localhash_id =$alarmdb= array();
			$alarmsql = "SELECT * FROM ps_alarm WHERE verifiy='$checktype'";
			$alarmquery = $dp->query($alarmsql);
			while($ls = $dp->fetch_array($alarmquery))
			{
				$localhash_id[] = $ls['localhash_id'];
				$alarmdb[$ls['localhash_id']] = $ls['alarmcontent'];
			}
			
			$inid = implode(',',$localhash_id);
			if(empty($inid))
			{
				$filtered = "WHERE id IN (-1,-2)";
			}
			else 
			{
				$filtered = "WHERE id IN ($inid)";
			}
		}
		else 
		{
			$var = 'checked'.$checktype;
			$$var = 'checked="checked"';
			if($checktype!=100)
			$filtered = "WHERE verifiy='$checktype'";
		}
	}
	if(!empty($checkword))
	{
		$gbkcheckword = mb_convert_encoding($checkword,'gbk','utf-8');
		//!empty($filtered) ? $filtered .= " AND realname like '%$checkword%'" : $filtered = "WHERE realname like '%$checkword%' ";
		!empty($filtered) ? $filtered .= " AND seedname like '%$gbkcheckword%'" : $filtered = "WHERE seedname like '%$gbkcheckword%' ";
	}
	if(!empty($thash))
	{
		if(!$filtered)
		{
			$filtered=" where hash='$thash'";
		}
		else
			$filtered.=" and hash='$thash' ";
	}
	
	if(!empty($stime))
	{
		if(!$filtered)
		{
			$filtered=" where uptime>='$stime' and uptime<='$etime'";
		}
		else
			$filtered.=" and uptime>='$stime' and uptime<='$etime' ";
	}
	if(!empty($completed))
	{
		if($completed==-1) $completed=0;
		if(!$filtered)
		{
			$filtered=" where completed='$completed' ";
		}
		else
			$filtered.=" and  completed='$completed'  ";
	}

	if(!empty($btcid))
	{
		if(!$filtered)
		{
			$filtered=" where btcid='$btcid'";
		}
		else
			$filtered.=" and btcid='$btcid'";
	}
	if($ishot == 1)
	{
		$filtered.=" order by clicktimes desc  ";
	}else
	{
		$filtered.=" order by id desc ";
		
	}
	if(!empty($md5filtered)&&!$searkw)
	{
		$filtered = str_replace('*','=',urldecode($md5filtered));
		$filtered = stripslashes($filtered);
	}
		
	$sql="SELECT COUNT(*) AS num FROM $table $filtered";
	//echo "sql=".$sql;die();
	$query = $db->query($sql);
	$totalnum = $db->result($query,0);
	$perpage = 1;
	$totalpages = ceil($totalnum/$perpage);
	if(!isset($page)||!is_numeric($page))
	{
		$page = 1;
	}
	$page = (int)$page;
	if($page>$totalpages||$page<1)
	{
		$page = 1;
	}
	$start_limit = ($page-1)*$perpage;
	$md5filtered = urlencode(str_replace('=','*',$filtered));
	$pages=numofpage($totalnum,$page,$totalpages,"man.inc.php?action=$action&md5filtered=$md5filtered&");
	$checkdb = array();

	$sql1 = "SELECT * FROM $table $filtered  LIMIT $start_limit,$perpage ";
	//echo '<!--sql1='.$sql1.'-->';//debug
	$query = $db->query($sql1);
	while ($checkli = $db->fetch_array($query))
	{
		$checkli['seedname'] = mb_convert_encoding($checkli['seedname'],'utf-8','gbk');
		$checkli['shortname']=cutstr($checkli['seedname'],20);
		$checkli['fname']=urlencode($checkli['seedname']);
		if(!eregi("[\x7F-\xFF]+",$checkli['realname']))
		{
			$checkli['realname']=$checkli['seedname'];
		}
		if($checkli['verifiy']==1)
		{
			$checkli['checkinfo'] = '正常状态';
		}
		elseif ($checkli['verifiy']==0)
		{
			$checkli['checkinfo'] = '正常状态';
		}
		elseif ($checkli['verifiy']==2)
		{
			$checkli['checkinfo'] = '自动替换';
		}
		elseif ($checkli['verifiy']==3)
		{
			$checkli['checkinfo'] = '自动禁止';
		}
		elseif ($checkli['verifiy']==4)
		{
			$checkli['checkinfo'] = '人工通过';
		}
		elseif ($checkli['verifiy']==5)
		{
			$checkli['checkinfo'] = '人工禁止';
		}
		elseif ($checkli['verifiy']==7)
		{
			$checkli['checkinfo'] = '人工加热';
		}
		elseif ($checkli['verifiy']==6)
		{
			$checkli['checkinfo'] = '人工置顶';
		}
		elseif ($checkli['verifiy']==8)
		{
			$checkli['checkinfo'] = '强制过滤';
		}
		if(!empty($alarmdb))
		{
			$checkli['alarm'] =$alarmdb[$checkli['id']];
		}
		else 
		{
			$checkli['alarm'] = '';
		}
		//完成状态判断操作
		if($checkli['completed'] ==1)
			$checkli['completed']='<span style="color:blue;">是</span>';
		else
			$checkli['completed']='<span style="color:red;">否</span';
			
		//举报类别说明：-1色情，-2反党，-3反人民，-4反社会，-5其它
		if($checkli['completed'])	
		
		$checkdb[] = $checkli;
	}
}
elseif ('delete'==$action)
{
	
	if($opertype!=0&&empty($opertype))
	{
		adminmsg('请选择动作','man.inc.php');
	}
	$opertype = (int)$opertype;
	echo "测试值为：".print_r($opertype);die();
	foreach ($checkhash as $lihash)
	{
		$lihash = trim($lihash);
		$hashlength = strlen($lihash);
		if($hashlength>40||$hashlength<40)
		{
			continue;
		}
		if($opertype!=99)//需要修改的地方
		{
			if($opertype==9) $opertype=7;
			$db->query("UPDATE $table SET verifiy='$opertype' WHERE hash='$lihash'");
		
		}
		else
		{
			$lihashname = $lihash.'_name';
			$hash_name = ${$lihashname};
			if(isset($hash_name)&&!empty($hash_name))
			{
				$db->query("UPDATE $table SET realname='$hash_name' WHERE hash='$lihash'");
			}
		}
	}
	adminmsg('操作成功，正在返回',"man.inc.php?action=checksearch&md5filtered=$md5filtered&page=$page");
}else{
	$sql="SELECT COUNT(*) AS num FROM $table ";
	//echo "sql=".$sql;die();
	$query = $db->query($sql);
	$totalnum = $db->result($query,0);
	$perpage = 1;
	$totalpages = ceil($totalnum/$perpage);
	if(!isset($page)||!is_numeric($page))
	{
		$page = 1;
	}
	$page = (int)$page;
	if($page>$totalpages||$page<1)
	{
		$page = 1;
	}
	$start_limit = ($page-1)*$perpage;
	$md5filtered = urlencode(str_replace('=','*',$filtered));
	$pages=numofpage($totalnum,$page,$totalpages,"man.inc.php?action=$action&md5filtered=$md5filtered&");
	$checkdb = array();

	$sql1 = "SELECT * FROM $table $filtered  LIMIT $start_limit,$perpage ";
	$query = $db->query($sql1);
	while ($checkli = $db->fetch_array($query))
	{
		$checkli['seedname'] = mb_convert_encoding($checkli['seedname'],'utf-8','gbk');
		$checkli['shortname']=cutstr($checkli['seedname'],20);
		$checkli['fname']=urlencode($checkli['seedname']);
		//完成状态判断操作
		if($checkli['completed'] ==1)
			$checkli['completed']='<span style="color:blue;">是</span>';
		else
			$checkli['completed']='<span style="color:red;">否</span';
			
		//举报类别说明：-1色情，-2反党，-3反人民，-4反社会，-5其它
		if($checkli['completed'])	
		
		$checkdb[] = $checkli;
	}
include_once 'templates/msystem/man.htm';

}

?>
